# -*- coding: utf-8 -*-
import tensorflow as tf

W = tf.Variable(2.0, dtype=tf.float32, name="Weight")
b = tf.Variable(1.0, dtype=tf.float32, name="Bias") # 偏差
x = tf.placeholder(dtype=tf.float32, name="Input") # 输入

with tf.name_scope("Output"):
    y = W * x + b

# 定义保存日志的路径
path = "./log"

# 创建用于初始化所有变量（Variable）的操作
init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init)
    writer = tf.summary.FileWriter(path, sess.graph)
    result = sess.run(y, {x: 3.0})
    print("y = %s" % result) # 打印 y = W * x + b 的值，就是 7
